<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索页面</title>
    <style>
        .search-container {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 100px;
        }

        .search-box {
            width: 300px;
            padding: 10px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 5px;
            outline: none;
        }

        .search-button {
            padding: 10px 20px;
            margin-left: 10px;
            font-size: 16px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .search-button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="search-container">
        <input type="text" id="searchQuery" class="search-box" placeholder="请输入搜索内容...">
        <button id="searchButton" class="search-button">搜索</button>
    </div>

    <script>
        document.getElementById("searchButton").addEventListener("click", function(event) {
            // 阻止表单的默认提交
            event.preventDefault();

            // 获取搜索框中的输入值
            const query = document.getElementById("searchQuery").value.trim();

            // 检查是否输入了搜索内容
            if (query === "") {
                alert("请输入搜索内容");
            } else {
                // 跳转到搜索结果页面，并传递搜索参数  在线
                const searchUrl = `online_search?query=${encodeURIComponent(query)}`;
                window.location.href = searchUrl;
            }
        });
    </script>
</body>
</html>